//
//  MainVisitorViewController.swift
//  weibo
//
//  Created by mac on 16/8/3.
//  Copyright © 2016年 zl. All rights reserved.
//

import UIKit

class MainVisitorViewController: UITableViewController {
    
    private var userlogin = false
    
    var visitorView : VisitorView?
    
    override func loadView() {
        
        userlogin ? super.loadView() : setupVisitorView()
    }
    
    private func setupVisitorView () {
        
        visitorView = VisitorView()
        

        
        view = visitorView
        
        visitorView?.registBtn.addTarget(self, action: "visitorDidRegist", forControlEvents: .TouchUpInside)
        visitorView?.loginBtn.addTarget(self, action: "visitorDidLogin", forControlEvents: .TouchUpInside)
        
        
        //设置导航栏按钮
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "visitorDidRegist")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "visitorDidLogin")
        
   
    }
    

}


extension  MainVisitorViewController   {
    func visitorDidRegist () {
        
        print("注册")
    }
    
    func visitorDidLogin () {
        
        let vc = AuthViewController()
        
        let nav = UINavigationController(rootViewController: vc)
        
        presentViewController(nav, animated: true, completion: nil)
        
        
    }
}
